home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 2 / MacMania 2.toast / Demo's / Tools&Utilities / Updaters / Symantec C++⁄MPW 6.0.1 / SCpp 6.0.1 Update / MacApp / MABuildTool.p < prev    next >
Encoding:
Text File  |  1993-08-10  |  58.4 KB  |  2,237 lines  |  [TEXT/MPS ]

  1. {[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]}
  2. {------------------------------------------------------------------------------
  3.  
  4. FILE MABuildTool.p
  5.  Copyright © 1986-1992 Apple Computer, Inc.  All rights reserved.
  6.  
  7. NAME
  8.  MABuild -- process MABuild options
  9.  
  10. SYNOPSIS
  11.  MABuild
  12.  
  13. DESCRIPTION
  14. ------------------------------------------------------------------------------}
  15. PROGRAM MABuild;
  16.  
  17.     USES Types, MacAppTypes,
  18.         {}
  19.          Memory, UPascalObject, UObject,
  20.  
  21.         { • Building Blocks }
  22.          UPascalTool,
  23.  
  24.         { • Implementation use }
  25.          UFailure, UList, UAssociation, TextEdit, OSUtils, Editions, Notification,
  26.          AppleEvents, UMacAppUtilities, CursorCtl, Signal, PasLibIntf, IntEnv, 
  27.          ToolUtils, Packages;
  28.  
  29.     CONST
  30.         { Keyword IDs }
  31.         kwAsm                = 1;
  32.         kwC                 = 2;
  33.         kwCPlus             = 3;
  34.         kwLib                = 4;
  35.         kwLink                = 5;
  36.         kwMake                = 6;
  37.         kwPascal            = 7;
  38.         kwRez                = 8;
  39.         kwCreatorAndBundle    = 9;
  40.         kwd                 = 10;
  41.         kwRenameFlag        = 11;
  42.         kwPP                = 12;
  43.         kwNoPP                = 13;
  44.         kwTT                = 14;
  45.         kwNoTT                = 15;
  46.         kwAlign             = 16;
  47.         kwNoAlign            = 17;
  48.         kwSeparateObjects    = 18;
  49.         kwNoSeparateObjects = 19;
  50.         kwExecute            = 20;
  51.         kwNoExecute         = 21;
  52.         kwFail                = 22;
  53.         kwNoFail            = 23;
  54.         kwLinkMap            = 24;
  55.         kwNoLinkMap         = 25;
  56.         kwLinkXRef            = 26;
  57.         kwNoLinkXRef        = 27;
  58.         kwAutoBuild         = 28;
  59.         kwNoAutoBuild        = 29;
  60.         kwUserAutoBuild     = 30;
  61.         kwNoUserAutoBuild    = 31;
  62.         kwMacApp            = 32;
  63.         kwNoMacApp            = 33;
  64.         kwDebug             = 36;
  65.         kwNoDebug            = 37;
  66.         kwBottleNeck        = 38;
  67.         kwNoBottleNeck        = 39;
  68.         kwExpandEnvVars     = 40;
  69.         kwNoExpandEnvVars    = 41;
  70.         kwSave                = 42;
  71.         kwNoSave            = 43;
  72.         kwRun                = 44;
  73.         kwNoRun             = 45;
  74.         kwUnInit            = 49;
  75.         kwNoUnInit            = 50;
  76.         kwRangeCheck        = 51;
  77.         kwNoRangeCheck        = 52;
  78.         kwNames             = 53;
  79.         kwNoNames            = 54;
  80.         kwSym                = 55;
  81.         kwNoSym             = 56;
  82.         kwNeedsColorQD        = 61;
  83.         kwNoNeedsColorQD    = 62;
  84.         kwPerform            = 63;
  85.         kwNoPerform         = 64;
  86.         kwNeedsSystem7        = 65;
  87.         kwNoNeedsSystem7    = 66;
  88.         kwNeedsMC68020        = 68;
  89.         kwNoNeedsMC68020    = 69;
  90.         kwNeedsMC68030        = 70;
  91.         kwNoNeedsMC68030    = 71;
  92.         kwNeedsFPU            = 72;
  93.         kwNoNeedsFPU        = 73;
  94.         kwTemplateViews     = 74;
  95.         kwNoTemplateViews    = 75;
  96.         kwWriteTemplateViews = 76;
  97.         kwNoWriteTemplateViews = 77;
  98.         kwTwoOhTemplateViews = 78;
  99.         kwNoTwoOhTemplateViews = 79;
  100.         kwStatusOnly        = 80;
  101.         kwNoStatusOnly        = 81;
  102.         kwE                 = 82;
  103.         kwR                 = 83;
  104.         kwS                 = 84;
  105.  
  106.         kwMALibrary         = 85;
  107.         kwNoMALibrary        = 86;
  108.  
  109.         kwPasLoad            = 91;
  110.         kwNoPasLoad         = 92;
  111.         
  112.         kwPasLoadSeparateFolder = 93;
  113.         kwNoPasLoadSeparateFolder = 94;
  114.  
  115.         kwCPlusLoad         = 95;
  116.         kwNoCPlusLoad        = 96;
  117.  
  118.         kwModelFar            = 97;
  119.         kwNoModelFar        = 98;
  120.  
  121.         kwDebugMsg            = 99;
  122.         kwNoDebugMsg        = 100;
  123.         
  124.         kwSymantec            = 101;
  125.         kwNoSymantec            = 102;
  126.         
  127.         kwSCpp                = 103;
  128.         kwCPlusPlus            = 104;
  129.         
  130.         kwBuildFolder        = 105;                        { Optional folder to place the object folders for a build in }
  131.  
  132.         kwNeedsVU            = 107;                        { Optional Virtual User support. }
  133.         kwNoNeedsVU            = 108;
  134.         
  135.         kwTheDebugger        = 109;                        { Optional The Debugger support }
  136.         kwNoTheDebugger        = 110;
  137.         
  138.         kHelpStr            = 129;                        { Resource ID of the stringlist printed for
  139.                                                          help }
  140.  
  141.     TYPE
  142.         TextPtr             = ^TEXT;
  143.  
  144.         TStringHandle        = OBJECT (TObject)
  145.             fHandle:            Handle;
  146.             PROCEDURE TStringHandle.WriteToFile(theFile: TextPtr);
  147.             PROCEDURE TStringHandle.Catenate(theString: Str255);
  148.             PROCEDURE TStringHandle.CatenateToFront(theString: Str255);
  149.             PROCEDURE TStringHandle.IStringHandle;
  150.             FUNCTION TStringHandle.AsStr255: Str255;
  151.             PROCEDURE TStringHandle.Free; OVERRIDE;
  152.             END;
  153.  
  154.         TMABuildTool        = OBJECT (TPascalTool)
  155.             fMacApp:            Boolean;
  156.  
  157.             fDebug:             Boolean;
  158.             fDebugMsg:            Boolean;
  159.             fNames:             Boolean;
  160.             fRangeCheck:        Boolean;
  161.             fPerform:            Boolean;
  162.             fSym:                Boolean;
  163.             fUnInit:            Boolean;
  164.             fAlign:             Boolean;
  165.             fSeparateObjects:    Boolean;
  166.             fSeparateObjectsFolder: Str255;
  167.             fBuildFolder:        Str255;
  168.             fMALibrary:         Boolean;
  169.             fPasLoad:            Boolean;                { Dump pascal symbol table info }
  170.             fPasLoadSeparateFolder: Boolean;            { Make Pascal's symbol table dumps external
  171.                                                          files instead of the default of using the
  172.                                                          source file's resource fork }
  173.             fCPlusLoad:         Boolean;                { Create load/dump files for C++ }
  174.  
  175.             fModelFar:            Boolean;
  176.             fNeedsColorQD:        Boolean;
  177.             fNeedsMC68020:        Boolean;
  178.             fNeedsMC68030:        Boolean;
  179.             fNeedsFPU:            Boolean;
  180.             fNeedsSystem7:        Boolean;
  181.             fTemplateViews:     Boolean;
  182.             fWriteTemplateViews: Boolean;
  183.             fTwoOhTemplateViews: Boolean;
  184.  
  185.             fAllProgress:        Boolean;
  186.             fExecute:            Boolean;
  187.             fAutoBuild:         Boolean;
  188.             fUserAutoBuild:     Boolean;
  189.             fNoFail:            Boolean;
  190.             fLinkMap:            Boolean;
  191.             fLinkXRef:            Boolean;
  192.             fStatusOnly:        Boolean;
  193.             fTimes:             Boolean;
  194.             fRunAfterBuild:     Boolean;
  195.             fSaveBeforeBuild:    Boolean;
  196.             fBottleNeckedDispatching: Boolean;
  197.             fExpandEnvironmentVars: Boolean;
  198.  
  199.             fEverExported:        Boolean;                { only need to export once }
  200.             
  201.             fSymantec:            Boolean;                { Use the Symantec compiler? }
  202.             
  203.             fNeedsVU:            Boolean;                { Virtual User option. }
  204.  
  205.             fTheDebugger:        Boolean;                { The Debugger option. }
  206.  
  207.             { The following is split out from other compiler options because UMacAppUniversal.cp
  208.               must be compiled to run on 68000 machines. The CPlus compiler does not have compiler
  209.               directives to control machine options. It can only be controlled from the command
  210.               line. }
  211.  
  212.             fCPlusCPUOptions:    TStringHandle;
  213.             fPascalCPUOptions:    TStringHandle;
  214.             
  215.             fAsmOptions:        TStringHandle;
  216.             fCOptions:            TStringHandle;
  217.             fCPlusOptions:        TStringHandle;
  218.             fSCOptions:        TStringHandle;
  219.             fEchoOptions:        TStringHandle;
  220.             fLibOptions:        TStringHandle;
  221.             fLinkOptions:        TStringHandle;
  222.             fMakeOptions:        TStringHandle;
  223.             fPascalOptions:     TStringHandle;
  224.             fRezOptions:        TStringHandle;
  225.             fCreatorAndBundleOptions:    TStringHandle;
  226.  
  227.             fTargStringList:    TList;
  228.             fOptionFlags:        TStringHandle;
  229.  
  230.             fOutputFile:        TextPtr;
  231.  
  232.             fStartPath:            Str255;
  233.  
  234.             fRenameFlagsPairs:    TAssociation;
  235.  
  236.             PROCEDURE TMABuildTool.IMABuildTool;
  237.  
  238.             PROCEDURE TMABuildTool.DoProcessFileArg(arg: Str255); OVERRIDE;
  239.             PROCEDURE TMABuildTool.DoProcessOptionArg(kw: integer); OVERRIDE;
  240.             PROCEDURE TMABuildTool.DoShowUsage; OVERRIDE;
  241.             PROCEDURE TMABuildTool.DoStartProgress; OVERRIDE;
  242.             PROCEDURE TMABuildTool.DoToolAction; OVERRIDE;
  243.             PROCEDURE TMABuildTool.DoAllTargets;
  244.             PROCEDURE TMABuildTool.InstallKeyWords; OVERRIDE;
  245.             PROCEDURE TMABuildTool.EachSourceToolOptionStringDo(PROCEDURE
  246.                                                                 DoToOptionString(itsStringHandle:
  247.                                                                                  TStringHandle));
  248.             PROCEDURE TMABuildTool.CatenateToSourceOptionStrings(newText: Str255);
  249.             PROCEDURE TMABuildTool.Echo(aStr: Str255);
  250.             PROCEDURE TMABuildTool.Execute(aStr: Str255);
  251.             PROCEDURE TMABuildTool.SetIE(theVariable: Str255;
  252.                                          theValue: Str255); { output a set instruction }
  253.             FUNCTION TMABuildTool.Exists(theFile: Str255): Boolean;
  254.             END;
  255.  
  256.     VAR
  257.         gMABuildTool:        TMABuildTool;                { The tool }
  258.         gDirectorySeparator: Str255;                    { : or / as required by host filesystem }
  259.         gBuildFolder, gMAObjFolder: Str255;                { Global to avoid stack overrun. }
  260.  
  261. {--------------------------------------------------------------------------------------------------}
  262. {$S TRes}
  263.  
  264.     FUNCTION NewTStringHandle: TStringHandle;
  265.  
  266.         VAR
  267.             aTStringHandle:     TStringHandle;
  268.  
  269.         BEGIN
  270.         New(aTStringHandle);
  271.         aTStringHandle.IStringHandle;
  272.         NewTStringHandle := aTStringHandle;
  273.         END;
  274.  
  275. {--------------------------------------------------------------------------------------------------}
  276. {$S TRes}
  277.  
  278.     PROCEDURE TStringHandle.WriteToFile(theFile: TextPtr);
  279.  
  280.         VAR
  281.             remaining:            integer;
  282.             aString:            Str255;
  283.             thisTime, offset:    integer;
  284.  
  285.         BEGIN
  286.         remaining := GetHandleSize(fHandle);
  287.         offset := 0;
  288.         WHILE remaining > 0 DO
  289.             BEGIN
  290.             IF remaining > 255 THEN
  291.                 thisTime := 255
  292.             ELSE
  293.                 thisTime := remaining;
  294.             remaining := remaining - thisTime;
  295.             BlockMove(Ptr(ord(fHandle^) + offset), Ptr(@aString[1]), thisTime);
  296.             offset := offset + thisTime;
  297.             aString[0] := chr(thisTime);
  298.             Write(theFile^, aString);
  299.             END;
  300.         END;
  301.  
  302. {--------------------------------------------------------------------------------------------------}
  303. {$S TRes}
  304.  
  305.     FUNCTION TStringHandle.AsStr255: Str255;
  306.  
  307.         VAR
  308.             aString:            Str255;
  309.  
  310.         BEGIN
  311.         aString[0] := chr(min(GetHandleSize(fHandle), 255));
  312.         BlockMove(fHandle^, Ptr(@aString[1]), length(aString));
  313.         AsStr255 := aString;
  314.         END;
  315.  
  316. {--------------------------------------------------------------------------------------------------}
  317. {$S TRes}
  318.  
  319.     PROCEDURE TStringHandle.IStringHandle;
  320.  
  321.         VAR
  322.             aHandle:            Handle;
  323.  
  324.         BEGIN
  325.         fHandle := NIL;
  326.         aHandle := NewHandle(0);
  327.         FailNil(aHandle);
  328.         fHandle := aHandle;
  329.         END;
  330.  
  331. {--------------------------------------------------------------------------------------------------}
  332. {$S TRes}
  333.  
  334.     PROCEDURE TStringHandle.Free;
  335.  
  336.         BEGIN
  337.         fHandle := DisposeIfHandle(fHandle);
  338.         inherited Free;
  339.         END;
  340.  
  341. {--------------------------------------------------------------------------------------------------}
  342. {$S TRes}
  343.  
  344.     PROCEDURE TStringHandle.Catenate(theString: Str255);
  345.  
  346.         VAR
  347.             aLong:                Longint;
  348.  
  349.         BEGIN
  350.         aLong := Munger(fHandle, GetHandleSize(fHandle), NIL, 0, { force insertion }
  351.                         Ptr(@theString[1]), length(theString));
  352.         FailMemError;
  353.         END;
  354.  
  355. {--------------------------------------------------------------------------------------------------}
  356. {$S TRes}
  357.  
  358.     PROCEDURE TStringHandle.CatenateToFront(theString: Str255);
  359.  
  360.         VAR
  361.             aLong:                Longint;
  362.  
  363.         BEGIN
  364.         aLong := Munger(fHandle, 0, NIL, 0,             { force insertion }
  365.                         Ptr(@theString[1]), length(theString));
  366.         FailMemError;
  367.         END;
  368.  
  369. {--------------------------------------------------------------------------------------------------}
  370. {$S TRes}
  371.  
  372.     PROCEDURE TMABuildTool.DoShowUsage;
  373.  
  374.         VAR
  375.             theHelpString:        Str255;
  376.             i:                    integer;
  377.  
  378.         BEGIN
  379.         PLFlush(diagnostic);
  380.         PLSetVBuf(diagnostic, NIL, _IOFBF, 4096);
  381.  
  382.         { output each string in the stringlist }
  383.         i := 1;
  384.         GetIndString(theHelpString, kHelpStr, i);
  385.         WHILE (theHelpString <> '') DO
  386.             BEGIN
  387.             WriteLn(diagnostic, theHelpString);
  388.             i := succ(i);
  389.             GetIndString(theHelpString, kHelpStr, i);
  390.             END;
  391.         END;
  392.  
  393. {--------------------------------------------------------------------------------------------------}
  394. {$S TInit}
  395.  
  396.     PROCEDURE TMABuildTool.DoProcessFileArg(arg: Str255);
  397.  
  398.         VAR
  399.             aStringHandle:        TStringHandle;
  400.  
  401.         BEGIN
  402.         { Special case for MacApp as target for backward compatibility (until post 2.0)}
  403.         IF EqualString(arg, 'MacApp', FALSE, TRUE) THEN
  404.             fAutoBuild := TRUE
  405.         ELSE
  406.             BEGIN
  407.             aStringHandle := NewTStringHandle;
  408.             aStringHandle.Catenate(arg);
  409.             fTargStringList.InsertLast(aStringHandle);
  410.             END;
  411.         END;
  412.  
  413. {--------------------------------------------------------------------------------------------------}
  414. {$S TInit}
  415.  
  416.     PROCEDURE TMABuildTool.DoStartProgress;
  417.  
  418.         VAR
  419.             theDateTimeString:    Str255;
  420.  
  421.         BEGIN
  422.         IUTimeString(fStartDateTime, TRUE, theDateTimeString);
  423.         Write(diagnostic, gProgName, ' - v. 3.0.1 Release ', compdate, '          Start: ',
  424.               theDateTimeString);
  425.  
  426.         IUDateString(fStartDateTime, shortDate, theDateTimeString);
  427.         WriteLn(diagnostic, ' ', theDateTimeString);
  428.  
  429.         WriteLn(diagnostic);
  430.         WriteLn(diagnostic, 'Copyright Apple Computer, Inc. 1986-1992');
  431.         WriteLn(diagnostic, 'All Rights Reserved.');
  432.         WriteLn(diagnostic);
  433.         PLFlush(diagnostic);
  434.         END;
  435.  
  436. {--------------------------------------------------------------------------------------------------}
  437. {$S TRes}
  438.  
  439.     PROCEDURE TMABuildTool.EachSourceToolOptionStringDo(PROCEDURE
  440.                                                         DoToOptionString(itsStringHandle:
  441.                                                                          TStringHandle));
  442.  
  443.         BEGIN
  444.         DoToOptionString(fAsmOptions);
  445.         DoToOptionString(fCOptions);
  446.         DoToOptionString(fCPlusOptions);
  447.         DoToOptionString(fSCOptions);
  448.         DoToOptionString(fMakeOptions);
  449.         DoToOptionString(fPascalOptions);
  450.         DoToOptionString(fRezOptions);
  451.         END;
  452.  
  453. {--------------------------------------------------------------------------------------------------}
  454. {$S TRes}
  455.  
  456.     PROCEDURE TMABuildTool.CatenateToSourceOptionStrings(newText: Str255);
  457.  
  458.         PROCEDURE DoToOptionString(itsStringHandle: TStringHandle);
  459.  
  460.             BEGIN
  461.             itsStringHandle.Catenate(newText);
  462.             END;
  463.  
  464.         BEGIN
  465.         EachSourceToolOptionStringDo(DoToOptionString);
  466.         END;
  467.  
  468. {--------------------------------------------------------------------------------------------------}
  469. {$S TInit}
  470.  
  471.     PROCEDURE TMABuildTool.DoProcessOptionArg(kw: integer);
  472.  
  473.         VAR
  474.             theNextArg:         Str255;
  475.  
  476.         BEGIN
  477.         CASE kw OF
  478.             kwAsm:
  479.                 BEGIN
  480.                 fAsmOptions.Catenate(' ');
  481.                 fAsmOptions.Catenate(GetNextArg);
  482.                 END;
  483.  
  484.             kwC:
  485.                 BEGIN
  486.                 fCOptions.Catenate(' ');
  487.                 fCOptions.Catenate(GetNextArg);
  488.                 END;
  489.             
  490.             { Options for any C++ compiler. }
  491.             kwCPlusPlus:
  492.                 BEGIN
  493.                 theNextArg := GetNextArg;
  494.                 fCPlusOptions.Catenate(' ');
  495.                 fCPlusOptions.Catenate(theNextArg);
  496.                 fSCOptions.Catenate(' ');
  497.                 fSCOptions.Catenate(theNextArg);
  498.                 END;
  499.  
  500.             { Options for CPlus, AT&T's CFront. }
  501.             kwCPlus:
  502.                 BEGIN
  503.                 fCPlusOptions.Catenate(' ');
  504.                 fCPlusOptions.Catenate(GetNextArg);
  505.                 END;
  506.                 
  507.             { Options for Symantec C++ compiler. }
  508.             kwSCpp:
  509.                 BEGIN
  510.                 fSCOptions.Catenate(' ');
  511.                 fSCOptions.Catenate(GetNextArg);
  512.                 END;
  513.  
  514.             kwLib:
  515.                 BEGIN
  516.                 fLibOptions.Catenate(' ');
  517.                 fLibOptions.Catenate(GetNextArg);
  518.                 END;
  519.  
  520.             kwLink:
  521.                 BEGIN
  522.                 fLinkOptions.Catenate(' ');
  523.                 fLinkOptions.Catenate(GetNextArg);
  524.                 END;
  525.  
  526.             kwMake:
  527.                 BEGIN
  528.                 fMakeOptions.Catenate(' ');
  529.                 fMakeOptions.Catenate(GetNextArg);
  530.                 END;
  531.  
  532.             kwPascal:
  533.                 BEGIN
  534.                 fPascalOptions.Catenate(' ');
  535.                 fPascalOptions.Catenate(GetNextArg);
  536.                 END;
  537.  
  538.             kwRez:
  539.                 BEGIN
  540.                 fRezOptions.Catenate(' ');
  541.                 fRezOptions.Catenate(GetNextArg);
  542.                 END;
  543.  
  544.             kwCreatorAndBundle:
  545.                 BEGIN
  546.                 fCreatorAndBundleOptions.Catenate(' ');
  547.                 fCreatorAndBundleOptions.Catenate(GetNextArg);
  548.                 END;
  549.  
  550.             kwd:
  551.                 BEGIN
  552.                 theNextArg := GetNextArg;
  553.  
  554.                 fAsmOptions.Catenate(' -d ');
  555.                 fAsmOptions.Catenate(theNextArg);
  556.  
  557.                 fCOptions.Catenate(' -d ');
  558.                 fCOptions.Catenate(theNextArg);
  559.  
  560.                 fCPlusOptions.Catenate(' -d ');
  561.                 fCPlusOptions.Catenate(theNextArg);
  562.  
  563.                 fSCOptions.Catenate(' -d ');
  564.                 fSCOptions.Catenate(theNextArg);
  565.  
  566.                 fMakeOptions.Catenate(' -d ');
  567.                 fMakeOptions.Catenate(theNextArg);
  568.  
  569.                 fPascalOptions.Catenate(' -d ');
  570.                 fPascalOptions.Catenate(theNextArg);
  571.  
  572.                 fRezOptions.Catenate(' -d ');
  573.                 fRezOptions.Catenate(theNextArg);
  574.  
  575.                 END;
  576.  
  577.             kwRenameFlag:
  578.                 BEGIN
  579.                 fRenameFlagsPairs.InsertEntry(GetNextArg, GetNextArg);
  580.                 END;
  581.  
  582.             kwPP:
  583.                 BEGIN
  584.                 fAllProgress := TRUE;
  585.                 fProgress := TRUE;
  586.                 END;
  587.             kwNoPP:
  588.                 BEGIN
  589.                 fAllProgress := FALSE;
  590.                 fProgress := FALSE;
  591.                 END;
  592.  
  593.             kwTT:
  594.                 BEGIN
  595.                 fTimes := TRUE;
  596.                 fTime := TRUE;
  597.                 END;
  598.             kwNoTT:
  599.                 BEGIN
  600.                 fTimes := FALSE;
  601.                 fTime := FALSE;
  602.                 END;
  603.  
  604.             kwAlign:
  605.                 fAlign := TRUE;
  606.             kwNoAlign:
  607.                 fAlign := FALSE;
  608.  
  609.             kwSeparateObjects:
  610.                 fSeparateObjects := TRUE;
  611.             kwNoSeparateObjects:
  612.                 fSeparateObjects := FALSE;
  613.  
  614.             kwBuildFolder:
  615.                 BEGIN
  616.                 theNextArg := GetNextArg;
  617.                 fBuildFolder := theNextArg;
  618.                 END;
  619.                 
  620.             kwExecute:
  621.                 fExecute := TRUE;
  622.             kwNoExecute:
  623.                 fExecute := FALSE;
  624.  
  625.             kwFail:
  626.                 fNoFail := FALSE;
  627.             kwNoFail:
  628.                 fNoFail := TRUE;
  629.  
  630.             kwLinkMap:
  631.                 fLinkMap := TRUE;
  632.             kwNoLinkMap:
  633.                 fLinkMap := FALSE;
  634.  
  635.             kwLinkXRef:
  636.                 fLinkXRef := TRUE;
  637.             kwNoLinkXRef:
  638.                 fLinkXRef := FALSE;
  639.  
  640.             kwAutoBuild:
  641.                 fAutoBuild := TRUE;
  642.             kwNoAutoBuild:
  643.                 fAutoBuild := FALSE;
  644.  
  645.             kwUserAutoBuild:
  646.                 fUserAutoBuild := TRUE;
  647.             kwNoUserAutoBuild:
  648.                 fUserAutoBuild := FALSE;
  649.  
  650.             kwMacApp:
  651.                 fMacApp := TRUE;
  652.             kwNoMacApp:
  653.                 fMacApp := FALSE;
  654.  
  655.             kwDebug:
  656.                 BEGIN
  657.                 fDebug := TRUE;
  658.                 fDebugMsg := TRUE;
  659.                 fUnInit := TRUE;
  660.                 fPerform := TRUE;
  661.                 fRangeCheck := TRUE;
  662.                 fNames := TRUE;
  663.                 fBottleNeckedDispatching := TRUE;
  664.                 END;
  665.             kwNoDebug:
  666.                 BEGIN
  667.                 fDebug := FALSE;
  668.                 fDebugMsg := FALSE;
  669.                 fUnInit := FALSE;
  670.                 fPerform := FALSE;
  671.                 fRangeCheck := FALSE;
  672.                 fNames := FALSE;
  673.                 fBottleNeckedDispatching := FALSE;
  674.                 END;
  675.                 
  676.             kwDebugMsg:
  677.                 fDebugMsg := TRUE;
  678.             kwNoDebugMsg:
  679.                 fDebugMsg := FALSE;
  680.  
  681.             kwBottleNeck:
  682.                 fBottleNeckedDispatching := TRUE;
  683.             kwNoBottleNeck:
  684.                 fBottleNeckedDispatching := FALSE;
  685.  
  686.             kwExpandEnvVars:
  687.                 fExpandEnvironmentVars := TRUE;
  688.             kwNoExpandEnvVars:
  689.                 fExpandEnvironmentVars := FALSE;
  690.  
  691.             kwSave:
  692.                 fSaveBeforeBuild := TRUE;
  693.             kwNoSave:
  694.                 fSaveBeforeBuild := FALSE;
  695.  
  696.             kwRun:
  697.                 fRunAfterBuild := TRUE;
  698.             kwNoRun:
  699.                 fRunAfterBuild := FALSE;
  700.  
  701.             kwUnInit:
  702.                 fUnInit := TRUE;
  703.             kwNoUnInit:
  704.                 fUnInit := FALSE;
  705.  
  706.             kwRangeCheck:
  707.                 fRangeCheck := TRUE;
  708.             kwNoRangeCheck:
  709.                 fRangeCheck := FALSE;
  710.  
  711.             kwNames:
  712.                 fNames := TRUE;
  713.             kwNoNames:
  714.                 fNames := FALSE;
  715.  
  716.             kwSym:
  717.                 fSym := TRUE;
  718.             kwNoSym:
  719.                 fSym := FALSE;
  720.  
  721.             kwNeedsColorQD:
  722.                 fNeedsColorQD := TRUE;
  723.             kwNoNeedsColorQD:
  724.                 fNeedsColorQD := FALSE;
  725.  
  726.             kwPerform:
  727.                 fPerform := TRUE;
  728.             kwNoPerform:
  729.                 fPerform := FALSE;
  730.  
  731.             kwNeedsSystem7:
  732.                 fNeedsSystem7 := TRUE;
  733.             kwNoNeedsSystem7:
  734.                 fNeedsSystem7 := FALSE;
  735.  
  736.             kwNeedsMC68020:
  737.                 fNeedsMC68020 := TRUE;
  738.             kwNoNeedsMC68020:
  739.                 fNeedsMC68020 := FALSE;
  740.  
  741.             kwNeedsMC68030:
  742.                 fNeedsMC68030 := TRUE;
  743.             kwNoNeedsMC68030:
  744.                 fNeedsMC68030 := FALSE;
  745.  
  746.             kwNeedsFPU:
  747.                 fNeedsFPU := TRUE;
  748.             kwNoNeedsFPU:
  749.                 fNeedsFPU := FALSE;
  750.  
  751.             kwTemplateViews:
  752.                 fTemplateViews := TRUE;
  753.             kwNoTemplateViews:
  754.                 fTemplateViews := FALSE;
  755.  
  756.             kwWriteTemplateViews:
  757.                 fWriteTemplateViews := TRUE;
  758.             kwNoWriteTemplateViews:
  759.                 fWriteTemplateViews := FALSE;
  760.  
  761.             kwTwoOhTemplateViews:
  762.                 fTwoOhTemplateViews := TRUE;
  763.             kwNoTwoOhTemplateViews:
  764.                 fTwoOhTemplateViews := FALSE;
  765.  
  766.             kwStatusOnly:
  767.                 BEGIN
  768.                 fExecute := FALSE;
  769.                 fStatusOnly := TRUE;
  770.                 END;
  771.             kwNoStatusOnly:
  772.                 BEGIN
  773.                 fExecute := TRUE;
  774.                 fStatusOnly := FALSE;
  775.                 END;
  776.  
  777.             kwE:
  778.                 fMakeOptions.Catenate(' -e');
  779.  
  780.             kwR:
  781.                 BEGIN
  782.                 fExecute := FALSE;
  783.                 fStatusOnly := TRUE;
  784.                 fMakeOptions.Catenate(' -r');
  785.                 END;
  786.  
  787.             kwS:
  788.                 BEGIN
  789.                 fExecute := FALSE;
  790.                 fStatusOnly := TRUE;
  791.                 fMakeOptions.Catenate(' -s');
  792.                 END;
  793.  
  794.             kwMALibrary:
  795.                 BEGIN
  796.                 fMALibrary := TRUE;
  797.                 END;
  798.  
  799.             kwNoMALibrary:
  800.                 BEGIN
  801.                 fMALibrary := FALSE;
  802.                 END;
  803.  
  804.             kwPasLoad:
  805.                 BEGIN
  806.                 fPasLoad := TRUE;
  807.                 END;
  808.  
  809.             kwNoPasLoad:
  810.                 BEGIN
  811.                 fPasLoad := FALSE;
  812.                 END;
  813.  
  814.             kwPasLoadSeparateFolder:
  815.                 BEGIN
  816.                 fPasLoadSeparateFolder := TRUE;
  817.                 END;
  818.  
  819.             kwNoPasLoadSeparateFolder:
  820.                 BEGIN
  821.                 fPasLoadSeparateFolder := FALSE;
  822.                 END;
  823.  
  824.             kwCPlusLoad:
  825.                 BEGIN
  826.                 fCPlusLoad := TRUE;
  827.                 END;
  828.  
  829.             kwNoCPlusLoad:
  830.                 BEGIN
  831.                 fCPlusLoad := FALSE;
  832.                 END;
  833.  
  834.             kwModelFar:
  835.                 BEGIN
  836.                 fModelFar := TRUE;
  837.                 END;
  838.  
  839.             kwNoModelFar:
  840.                 BEGIN
  841.                 fModelFar := FALSE;
  842.                 END;
  843.                 
  844.             kwSymantec:
  845.                 fSymantec := TRUE;
  846.             kwNoSymantec:
  847.                 fSymantec := FALSE;
  848.  
  849.             kwNeedsVU:
  850.                 fNeedsVU := TRUE;
  851.             kwNoNeedsVU:
  852.                 fNeedsVU := FALSE;
  853.  
  854.             kwTheDebugger:
  855.                 fTheDebugger := TRUE;
  856.             kwNoTheDebugger:
  857.                 fTheDebugger := FALSE;
  858.  
  859.             OTHERWISE
  860.                 inherited DoProcessOptionArg(kw);
  861.         END;
  862.  
  863.         END;
  864.  
  865. {--------------------------------------------------------------------------------------------------}
  866. {$S TInit}
  867.  
  868.     PROCEDURE TMABuildTool.IMABuildTool;
  869.  
  870.         VAR
  871.             anAssociation:        TAssociation;
  872.             aString:            Str255;
  873.  
  874.         BEGIN
  875.         IPascalTool;
  876.  
  877.         { Try to get the appropriate separator character for directories }
  878.         IF IEGetEnv('MADirectorySeparator', aString) THEN
  879.             gDirectorySeparator := aString
  880.         ELSE
  881.             gDirectorySeparator := ':';
  882.  
  883.         fOutputFile := @Output;
  884.         PLFlush(fOutputFile^);
  885.         PLSetVBuf(fOutputFile^, NIL, _IOFBF, 8192);
  886.  
  887.         fRenameFlagsPairs := NIL;
  888.         New(anAssociation);
  889.         anAssociation.IAssociation;
  890.         fRenameFlagsPairs := anAssociation;
  891.  
  892.         { setup the default options }
  893.         fMacApp := TRUE;
  894.  
  895.         fDebug := FALSE;
  896.         fDebugMsg := FALSE;
  897.         fNames := FALSE;
  898.         fPerform := FALSE;
  899.         fRangeCheck := FALSE;
  900.         fSym := FALSE;
  901.         fUnInit := FALSE;
  902.         fAlign := TRUE;
  903.         fSeparateObjects := TRUE;
  904.         fSeparateObjectsFolder := '';
  905.         fBuildFolder := '';
  906.         fMALibrary := TRUE;
  907.  
  908.         fPasLoad := FALSE;
  909.         fPasLoadSeparateFolder := TRUE;
  910.         
  911.         fCPlusLoad := TRUE;
  912.  
  913.         fModelFar := FALSE;
  914.  
  915.         fNeedsColorQD := FALSE;
  916.         fNeedsMC68020 := FALSE;
  917.         fNeedsMC68030 := FALSE;
  918.         fNeedsFPU := FALSE;
  919.         fNeedsSystem7 := FALSE;
  920.         fTemplateViews := TRUE;
  921.         fWriteTemplateViews := FALSE;
  922.         fTwoOhTemplateViews := FALSE;
  923.  
  924.         fAllProgress := FALSE;
  925.         fExecute := TRUE;
  926.         fAutoBuild := FALSE;
  927.         fUserAutoBuild := TRUE;
  928.         fNoFail := FALSE;
  929.         fProgress := FALSE;
  930.         fStatusOnly := FALSE;
  931.         fTimes := FALSE;
  932.         fLinkMap := FALSE;
  933.         fLinkXRef := FALSE;
  934.         fBottleNeckedDispatching := FALSE;
  935.         fRunAfterBuild := FALSE;
  936.         fSaveBeforeBuild := FALSE;
  937.         fExpandEnvironmentVars := FALSE;
  938.  
  939.         fEverExported := FALSE;
  940.         
  941.         fSymantec := FALSE;
  942.         
  943.         fNeedsVU := FALSE;
  944.         
  945.         fTheDebugger := FALSE;
  946.  
  947.         fCPlusCPUOptions := NIL;
  948.         fPascalCPUOptions := NIL;
  949.         fAsmOptions := NIL;
  950.         fCOptions := NIL;
  951.         fCPlusOptions := NIL;
  952.         fSCOptions := NIL;
  953.         fEchoOptions := NIL;
  954.         fLibOptions := NIL;
  955.         fLinkOptions := NIL;
  956.         fMakeOptions := NIL;
  957.         fPascalOptions := NIL;
  958.         fRezOptions := NIL;
  959.         fCreatorAndBundleOptions := NIL;
  960.  
  961.         fCPlusCPUOptions := NewTStringHandle;
  962.         fPascalCPUOptions := NewTStringHandle;
  963.         fAsmOptions := NewTStringHandle;
  964.         fCOptions := NewTStringHandle;
  965.         fCPlusOptions := NewTStringHandle;
  966.         fSCOptions := NewTStringHandle;
  967.         fEchoOptions := NewTStringHandle;
  968.         fLibOptions := NewTStringHandle;
  969.         fLinkOptions := NewTStringHandle;
  970.         fMakeOptions := NewTStringHandle;
  971.         fPascalOptions := NewTStringHandle;
  972.         fRezOptions := NewTStringHandle;
  973.         fCreatorAndBundleOptions := NewTStringHandle;
  974.  
  975.         fEchoOptions := NIL;
  976.         fTargStringList := NIL;
  977.         fOptionFlags := NIL;
  978.  
  979.         fEchoOptions := NewTStringHandle;
  980.  
  981.         fTargStringList := NewList;
  982.  
  983.         fOptionFlags := NewTStringHandle;
  984.  
  985.         END;
  986.  
  987. {--------------------------------------------------------------------------------------------------}
  988. {$S TInit}
  989.  
  990.     PROCEDURE TMABuildTool.InstallKeyWords;
  991.  
  992.         BEGIN
  993.         inherited InstallKeyWords;
  994.  
  995.         InstallKeyWord('Asm', kwAsm);
  996.         InstallKeyWord('C', kwC);
  997.         InstallKeyWord('CPlus', kwCPlus);
  998.         InstallKeyWord('Lib', kwLib);
  999.         InstallKeyWord('Link', kwLink);
  1000.         InstallKeyWord('Make', kwMake);
  1001.         InstallKeyWord('Pascal', kwPascal);
  1002.         InstallKeyWord('Rez', kwRez);
  1003.         InstallKeyWord('CreatorAndBundle', kwCreatorAndBundle);
  1004.         InstallKeyWord('d', kwd);
  1005.         InstallKeyWord('RenameFlag', kwRenameFlag);
  1006.         InstallKeyWord('PP', kwPP);
  1007.         InstallKeyWord('NoPP', kwNoPP);
  1008.         InstallKeyWord('TT', kwTT);
  1009.         InstallKeyWord('NoTT', kwNoTT);
  1010.         InstallKeyWord('Align', kwAlign);
  1011.         InstallKeyWord('NoAlign', kwNoAlign);
  1012.         InstallKeyWord('SeparateObjects', kwSeparateObjects);
  1013.         InstallKeyWord('NoSeparateObjects', kwNoSeparateObjects);
  1014.         InstallKeyWord('Execute', kwExecute);
  1015.         InstallKeyWord('NoExecute', kwNoExecute);
  1016.         InstallKeyWord('Fail', kwFail);
  1017.         InstallKeyWord('NoFail', kwNoFail);
  1018.         InstallKeyWord('LinkMap', kwLinkMap);
  1019.         InstallKeyWord('NoLinkMap', kwNoLinkMap);
  1020.         InstallKeyWord('LinkXRef', kwLinkXRef);
  1021.         InstallKeyWord('NoLinkXRef', kwNoLinkXRef);
  1022.         InstallKeyWord('AutoBuild', kwAutoBuild);
  1023.         InstallKeyWord('NoAutoBuild', kwNoAutoBuild);
  1024.         InstallKeyWord('UserAutoBuild', kwUserAutoBuild);
  1025.         InstallKeyWord('NoUserAutoBuild', kwNoUserAutoBuild);
  1026.         InstallKeyWord('MacApp', kwMacApp);
  1027.         InstallKeyWord('NoMacApp', kwNoMacApp);
  1028.         InstallKeyWord('Debug', kwDebug);
  1029.         InstallKeyWord('NoDebug', kwNoDebug);
  1030.         InstallKeyWord('DebugMsg', kwDebugMsg);
  1031.         InstallKeyWord('NoDebugMsg', kwNoDebugMsg);
  1032.         InstallKeyWord('BottleNeck', kwBottleNeck);
  1033.         InstallKeyWord('NoBottleNeck', kwNoBottleNeck);
  1034.         InstallKeyWord('ExpandEnvVars', kwExpandEnvVars);
  1035.         InstallKeyWord('NoExpandEnvVars', kwNoExpandEnvVars);
  1036.         InstallKeyWord('Save', kwSave);
  1037.         InstallKeyWord('NoSave', kwNoSave);
  1038.         InstallKeyWord('Run', kwRun);
  1039.         InstallKeyWord('NoRun', kwNoRun);
  1040.         InstallKeyWord('UnInit', kwUnInit);
  1041.         InstallKeyWord('NoUnInit', kwNoUnInit);
  1042.         InstallKeyWord('RangeCheck', kwRangeCheck);
  1043.         InstallKeyWord('NoRangeCheck', kwNoRangeCheck);
  1044.         InstallKeyWord('Names', kwNames);
  1045.         InstallKeyWord('NoNames', kwNoNames);
  1046.         InstallKeyWord('Sym', kwSym);
  1047.         InstallKeyWord('NoSym', kwNoSym);
  1048.         InstallKeyWord('NeedsColorQD', kwNeedsColorQD);
  1049.         InstallKeyWord('NoNeedsColorQD', kwNoNeedsColorQD);
  1050.         InstallKeyWord('Perform', kwPerform);
  1051.         InstallKeyWord('NoPerform', kwNoPerform);
  1052.         InstallKeyWord('NeedsSystem7', kwNeedsSystem7);
  1053.         InstallKeyWord('NoNeedsSystem7', kwNoNeedsSystem7);
  1054.         InstallKeyWord('NeedsMC68020', kwNeedsMC68020);
  1055.         InstallKeyWord('NoNeedsMC68020', kwNoNeedsMC68020);
  1056.         InstallKeyWord('NeedsMC68030', kwNeedsMC68030);
  1057.         InstallKeyWord('NoNeedsMC68030', kwNoNeedsMC68030);
  1058.         InstallKeyWord('NeedsFPU', kwNeedsFPU);
  1059.         InstallKeyWord('NoNeedsFPU', kwNoNeedsFPU);
  1060.         InstallKeyWord('TemplateViews', kwTemplateViews);
  1061.         InstallKeyWord('NoTemplateViews', kwNoTemplateViews);
  1062.         InstallKeyWord('WriteTemplateViews', kwWriteTemplateViews);
  1063.         InstallKeyWord('NoWriteTemplateViews', kwNoWriteTemplateViews);
  1064.         InstallKeyWord('TwoOhTemplateViews', kwTwoOhTemplateViews);
  1065.         InstallKeyWord('NoTwoOhTemplateViews', kwNoTwoOhTemplateViews);
  1066.         InstallKeyWord('StatusOnly', kwStatusOnly);
  1067.         InstallKeyWord('NoStatusOnly', kwNoStatusOnly);
  1068.         InstallKeyWord('E', kwE);
  1069.         InstallKeyWord('R', kwR);
  1070.         InstallKeyWord('S', kwS);
  1071.         InstallKeyWord('PasLoad', kwPasLoad);
  1072.         InstallKeyWord('NoPasLoad', kwNoPasLoad);
  1073.         InstallKeyWord('PasLoadSeparateFolder', kwPasLoadSeparateFolder);
  1074.         InstallKeyWord('NoPasLoadSeparateFolder', kwNoPasLoadSeparateFolder);
  1075.  
  1076.         InstallKeyWord('CPlusLoad', kwCPlusLoad);
  1077.         InstallKeyWord('NoCPlusLoad', kwNoCPlusLoad);
  1078.  
  1079.         InstallKeyWord('MALibrary', kwMALibrary);
  1080.         InstallKeyWord('NoMALibrary', kwNoMALibrary);
  1081.  
  1082.         InstallKeyWord('ModelFar', kwModelFar);
  1083.         InstallKeyWord('NoModelFar', kwNoModelFar);
  1084.  
  1085.         InstallKeyWord('Symantec', kwSymantec);
  1086.         InstallKeyWord('NoSymantec', kwNoSymantec);
  1087.         
  1088.         InstallKeyWord('SCpp', kwSCpp);
  1089.         InstallKeyWord('Ztc', kwSCpp);
  1090.         InstallKeyWord('CPlusPlus', kwCPlusPlus);
  1091.  
  1092.         InstallKeyWord('BuildFolder', kwBuildFolder);
  1093.  
  1094.         InstallKeyWord('NeedsVU', kwNeedsVU);
  1095.         InstallKeyWord('NoNeedsVU', kwNoNeedsVU);
  1096.  
  1097.         InstallKeyWord('TheDebugger', kwTheDebugger);
  1098.         InstallKeyWord('NoTheDebugger', kwNoTheDebugger);
  1099.  
  1100.         END;
  1101.  
  1102. {--------------------------------------------------------------------------------------------------}
  1103. {$S TRes}
  1104.  
  1105.     PROCEDURE TMABuildTool.Execute(aStr: Str255);
  1106.  
  1107.         BEGIN
  1108.         WriteLn(fOutputFile^, aStr);
  1109.         END;
  1110.  
  1111. {--------------------------------------------------------------------------------------------------}
  1112. {$S TRes}
  1113.  
  1114.     PROCEDURE TMABuildTool.SetIE(theVariable: Str255;
  1115.                                  theValue: Str255);
  1116.  
  1117.         BEGIN
  1118.         WriteLn(fOutputFile^, 'SET ', theVariable, ' "', theValue, '"');
  1119.         END;
  1120.  
  1121. {--------------------------------------------------------------------------------------------------}
  1122. {$S TRes}
  1123.  
  1124.     PROCEDURE TMABuildTool.Echo(aStr: Str255);
  1125.  
  1126.         BEGIN
  1127.         Write(fOutputFile^, '{MAEcho} ');
  1128.         WriteLn(fOutputFile^, aStr);
  1129.         END;
  1130.  
  1131. {--------------------------------------------------------------------------------------------------}
  1132. {$S TRes}
  1133.  
  1134.     FUNCTION TMABuildTool.Exists(theFile: Str255): Boolean;
  1135.     { Return TRUE if the file or directory exists }
  1136.  
  1137.         VAR
  1138.             fndrInfo:            FInfo;
  1139.             aCInfoPBRec:        CInfoPBRec;
  1140.  
  1141.         BEGIN
  1142.         WITH aCInfoPBRec DO
  1143.             BEGIN
  1144.             ioCompletion := NIL;
  1145.             ioNamePtr := @theFile;
  1146.             ioVRefNum := 0;
  1147.             ioFRefNum := 0;
  1148.             ioFDirIndex := 0;
  1149.             ioDirID := 0;
  1150.             END;
  1151.  
  1152.         Exists := (PBGetCatInfo(@aCInfoPBRec, FALSE) = noErr) & (aCInfoPBRec.IOResult = noErr);
  1153.         END;
  1154.  
  1155. {--------------------------------------------------------------------------------------------------}
  1156. {$S TRes}
  1157.  
  1158.     PROCEDURE TMABuildTool.DoAllTargets;
  1159.  
  1160.         VAR
  1161.             aTStringHandle:     TStringHandle;
  1162.             aString, bString, XAppPath, XAppName, MAMakeFileExtension, MASetupExtension: Str255;
  1163.             ObjApp, SrcApp, SeparateObjectsFolder, BuildFlags, MABuildFlagsExtension: Str255;
  1164.             i:                    integer;
  1165.             automake, autorez, anyPascal, anyCPlus: Boolean;
  1166.             dirID:                Longint;
  1167.             MAShellVersion:     Str255;
  1168.  
  1169.         BEGIN
  1170.         
  1171.         gBuildFolder := fBuildFolder;
  1172.         SeparateObjectsFolder := fSeparateObjectsFolder;
  1173.         
  1174.         { Define the MAObj folder. We do this here because its used in building
  1175.         each target. see 'Basic Definitions' }
  1176.         
  1177.         IF (length(gBuildFolder) > 0) THEN
  1178.             BEGIN
  1179.             gMAObjFolder := concat(gBuildFolder, 'MacApp.Lib', gDirectorySeparator, SeparateObjectsFolder);
  1180.             SetIE('MAObj', gMAObjFolder);
  1181.             
  1182.             IF NOT Exists(gBuildFolder) & (DirCreate(0, 0, gBuildFolder, dirID) <> noErr) THEN
  1183.                 BEGIN
  1184.                 Echo('''###'' MABuild: Unable to create the alternate build folder:');
  1185.                 Echo('MABuild of {XAppName} failed: `DATE`');
  1186.                 Execute('{MAFailed}');
  1187.  
  1188.                 IF fNoFail THEN
  1189.                     SetIE('XRunStatus', '1')
  1190.                 ELSE
  1191.                     Execute('EXIT 1');
  1192.                 END;
  1193.                 
  1194.             IF NOT Exists(concat(gBuildFolder, 'MacApp.Lib')) & (DirCreate(0, 0, concat(gBuildFolder, 'MacApp.Lib'), dirID) <> noErr) THEN
  1195.                 BEGIN
  1196.                 Echo('''###'' MABuild: Unable to create the alternate build folder:');
  1197.                 Echo('MABuild of {XAppName} failed: `DATE`');
  1198.                 Execute('{MAFailed}');
  1199.  
  1200.                 IF fNoFail THEN
  1201.                     SetIE('XRunStatus', '1')
  1202.                 ELSE
  1203.                     Execute('EXIT 1');
  1204.                 END;
  1205.                 
  1206.             IF NOT Exists(gMAObjFolder) & (DirCreate(0, 0, gMAObjFolder, dirID) <> noErr) THEN
  1207.                 BEGIN
  1208.                 Echo('''###'' MABuild: Unable to create the alternate build folder:');
  1209.                 Echo('MABuild of {XAppName} failed: `DATE`');
  1210.                 Execute('{MAFailed}');
  1211.  
  1212.                 IF fNoFail THEN
  1213.                     SetIE('XRunStatus', '1')
  1214.                 ELSE
  1215.                     Execute('EXIT 1');
  1216.                 END;
  1217.             END
  1218.         ELSE
  1219.             SetIE('MAObj', '{MALibraries}{SeparateObjectsFolder}');
  1220.  
  1221.         { Now process every target in fTargStringList }
  1222.         
  1223.         aTStringHandle := TStringHandle(fTargStringList.First);
  1224.  
  1225.         WHILE aTStringHandle <> NIL DO
  1226.             BEGIN
  1227.             fTargStringList.Delete(aTStringHandle);
  1228.  
  1229.             aString := aTStringHandle.AsStr255;         { Paths can't currently be longer than this
  1230.                                                          anyways! (MPW 3.1)}
  1231.  
  1232.             aTStringHandle.Free;
  1233.  
  1234.             { find the pathname and filename }
  1235.             XAppName := aString;
  1236.             XAppPath := '';
  1237.             FOR i := length(aString) DOWNTO 1 DO
  1238.                 BEGIN
  1239.                 IF Copy(aString, i, length(gDirectorySeparator)) = gDirectorySeparator THEN
  1240.                     BEGIN
  1241.                     XAppName := Copy(aString, i + 1, length(aString) - i);
  1242.                     XAppPath := Copy(aString, 1, i);
  1243.                     LEAVE;
  1244.                     END
  1245.                 END;
  1246.  
  1247.             { Automatically trim .MAMake off the target name if it was specified }
  1248.             IF IEGetEnv('MAMakeFileExtension', MAMakeFileExtension) & (MAMakeFileExtension <>
  1249.                '') THEN
  1250.                 BEGIN
  1251.                 aString := MAMakeFileExtension;
  1252.                 bString := XAppName;
  1253.                 UprStr255(aString);
  1254.                 UprStr255(bString);
  1255.                 i := pos(aString, bString);
  1256.                 IF (i <> 0) & (i + length(MAMakeFileExtension) - 1 = length(XAppName)) THEN
  1257.                     Delete(XAppName, i, length(MAMakeFileExtension));
  1258.                 END;
  1259.  
  1260.             { Blank path is current path }
  1261.             IF XAppPath = '' THEN
  1262.                 XAppPath := fStartPath;
  1263.  
  1264.             SetIE('XAppPath', XAppPath);
  1265.             SetIE('XAppName', XAppName);
  1266.  
  1267.             { Check for the  MASetupExtension file }
  1268.             IF IEGetEnv('MASetupExtension', MASetupExtension) & Exists(concat(XAppPath, XAppName,
  1269.                                                                        MASetupExtension)) THEN
  1270.                 WriteLn(fOutputFile^, 'EXECUTE "', concat(XAppPath, XAppName, MASetupExtension),
  1271.                         '"');
  1272.  
  1273.             { Process separate objects into the source and object pathnames… }
  1274.             IF (length(gBuildFolder) > 0) THEN
  1275.                 ObjApp := concat(gBuildFolder, XAppName, gDirectorySeparator, SeparateObjectsFolder)
  1276.             ELSE
  1277.                 ObjApp := concat(XAppPath, SeparateObjectsFolder);
  1278.             SrcApp := XAppPath;
  1279.             SetIE('ObjApp', ObjApp);
  1280.             SetIE('SrcApp', SrcApp);
  1281.  
  1282.             IF fProgress THEN
  1283.                 Echo('"Target Folder: ∂"{ObjApp}∂""');
  1284.  
  1285.             { Linkmap and LinkXref }
  1286.             IF fLinkMap THEN
  1287.                 BEGIN
  1288.                 IF fPerform THEN
  1289.                     SetIE('XLinkMap', '-la -lf -l > ∂''{ObjApp}{XAppName}.map∂'' ')
  1290.                 ELSE
  1291.                     SetIE('XLinkMap', '-map > ∂''{ObjApp}{XAppName}.map∂'' ');
  1292.                 END
  1293.             ELSE
  1294.                 SetIE('XLinkMap', '');
  1295.  
  1296.             IF fLinkXRef THEN
  1297.                 SetIE('XLinkXRef', '-x ∂''{ObjApp}{XAppName}.xref∂'' ')
  1298.             ELSE
  1299.                 SetIE('XLinkXRef', '');
  1300.  
  1301.             { Get various file names for autodependencies }
  1302.             { in Pascal }
  1303.             anyPascal := FALSE;
  1304.             IF Exists(concat(SrcApp, 'U', XAppName, '.p')) THEN
  1305.                 BEGIN
  1306.                 anyPascal := TRUE;
  1307.                 SetIE('XUAppName.p', concat(SrcApp, 'U', XAppName, '.p'));
  1308.                 SetIE('XUAppName.p.o', concat(ObjApp, 'U', XAppName, '.p.o'));
  1309.                 END
  1310.             ELSE
  1311.                 BEGIN
  1312.                 SetIE('XUAppName.p', '');
  1313.                 SetIE('XUAppName.p.o', '');
  1314.                 END;
  1315.  
  1316.             IF Exists(concat(SrcApp, 'M', XAppName, '.p')) THEN
  1317.                 BEGIN
  1318.                 anyPascal := TRUE;
  1319.                 SetIE('XMAppName.p', concat(SrcApp, 'M', XAppName, '.p'));
  1320.                 SetIE('XMAppName.p.o', concat(ObjApp, 'M', XAppName, '.p.o'));
  1321.                 END
  1322.             ELSE
  1323.                 BEGIN
  1324.                 SetIE('XMAppName.p', '');
  1325.                 SetIE('XMAppName.p.o', '');
  1326.                 END;
  1327.  
  1328.             IF Exists(concat(SrcApp, XAppName, '.p')) THEN
  1329.                 BEGIN
  1330.                 anyPascal := TRUE;
  1331.                 SetIE('XAppName.p', concat(SrcApp, XAppName, '.p'));
  1332.                 SetIE('XAppName.p.o', concat(ObjApp, XAppName, '.p.o'));
  1333.                 END
  1334.             ELSE
  1335.                 BEGIN
  1336.                 SetIE('XAppName.p', '');
  1337.                 SetIE('XAppName.p.o', '');
  1338.                 END;
  1339.  
  1340.             { you should wonder at how long this next chunk took to write! }
  1341.             SetIE('EXIT', '0');
  1342.             SetIE('XUAppName.inc.p', '`(Files "{SrcApp}"U{XAppName}.≈.p) ≥ dev:NULL`');
  1343.             SetIE('EXIT', '1');
  1344.  
  1345.             { in C++ }
  1346.             anyCPlus := FALSE;
  1347.             IF Exists(concat(SrcApp, 'U', XAppName, '.h')) THEN
  1348.                 BEGIN
  1349.                 anyCPlus := TRUE;
  1350.                 SetIE('XUAppName.h', concat(SrcApp, 'U', XAppName, '.h'));
  1351.                 END
  1352.             ELSE
  1353.                 BEGIN
  1354.                 SetIE('XUAppName.h', '');
  1355.                 END;
  1356.  
  1357.             IF Exists(concat(SrcApp, 'U', XAppName, '.cp')) THEN
  1358.                 BEGIN
  1359.                 anyCPlus := TRUE;
  1360.                 SetIE('XUAppName.cp', concat(SrcApp, 'U', XAppName, '.cp'));
  1361.                 SetIE('XUAppName.cp.o', concat(ObjApp, 'U', XAppName, '.cp.o'));
  1362.                 END
  1363.             ELSE
  1364.                 BEGIN
  1365.                 SetIE('XUAppName.cp', '');
  1366.                 SetIE('XUAppName.cp.o', '');
  1367.                 END;
  1368.  
  1369.             IF Exists(concat(SrcApp, 'M', XAppName, '.cp')) THEN
  1370.                 BEGIN
  1371.                 anyCPlus := TRUE;
  1372.                 SetIE('XMAppName.cp', concat(SrcApp, 'M', XAppName, '.cp'));
  1373.                 SetIE('XMAppName.cp.o', concat(ObjApp, 'M', XAppName, '.cp.o'));
  1374.                 END
  1375.             ELSE
  1376.                 BEGIN
  1377.                 SetIE('XMAppName.cp', '');
  1378.                 SetIE('XMAppName.cp.o', '');
  1379.                 END;
  1380.  
  1381.             IF Exists(concat(SrcApp, XAppName, '.cp')) THEN
  1382.                 BEGIN
  1383.                 anyCPlus := TRUE;
  1384.                 SetIE('XAppName.cp', concat(SrcApp, XAppName, '.cp'));
  1385.                 SetIE('XAppName.cp.o', concat(ObjApp, XAppName, '.cp.o'));
  1386.                 END
  1387.             ELSE
  1388.                 BEGIN
  1389.                 SetIE('XAppName.cp', '');
  1390.                 SetIE('XAppName.cp.o', '');
  1391.                 END;
  1392.  
  1393.             { See if we can automake it }
  1394.             IF NOT Exists(concat(XAppPath, XAppName, MAMakeFileExtension)) THEN
  1395.                 BEGIN
  1396.                 automake := TRUE;
  1397.                 IF NOT (anyPascal | anyCPlus) THEN
  1398.                     BEGIN
  1399.                     Echo(
  1400. '''###'' MABuild: Bad parameter: Unable to access file: "{XAppPath}{XAppName}{MAMakeFileExtension}"'
  1401.                          );
  1402.                     Echo('MABuild of {XAppName} failed: `DATE`');
  1403.                     Execute('{MAFailed}');
  1404.  
  1405.                     IF fNoFail THEN
  1406.                         SetIE('XExitStatus', '1')
  1407.                     ELSE
  1408.                         Execute('EXIT 1');
  1409.                     END
  1410.                 END
  1411.             ELSE
  1412.                 automake := FALSE;
  1413.  
  1414.             { See if we can autorez it }
  1415.             IF NOT Exists(concat(XAppPath, XAppName, '.r')) THEN
  1416.                 BEGIN
  1417.                 autorez := TRUE;
  1418.                 SetIE('XAutoRez', '1');
  1419.                 SetIE('XAppRezSrc', '{MARIncludes}Default.r');
  1420.                 END
  1421.             ELSE
  1422.                 BEGIN
  1423.                 autorez := FALSE;
  1424.                 SetIE('XAutoRez', '0');
  1425.                 SetIE('XAppRezSrc', '{XAppPath}{XAppName}.r');
  1426.                 END;
  1427.  
  1428.             { Make sure alternate build folder exists and AppName folder in build folder. }
  1429.             IF (length(gBuildFolder) > 0) THEN
  1430.                 BEGIN
  1431.                 IF NOT Exists(concat(gBuildFolder, XAppName)) & (DirCreate(0, 0, concat(gBuildFolder, XAppName), dirID) <> noErr) THEN
  1432.                     BEGIN
  1433.                     Echo('''###'' MABuild: Unable to create the alternate build folder:');
  1434.                     Echo('MABuild of {XAppName} failed: `DATE`');
  1435.                     Execute('{MAFailed}');
  1436.     
  1437.                     IF fNoFail THEN
  1438.                         SetIE('XRunStatus', '1')
  1439.                     ELSE
  1440.                         Execute('EXIT 1');
  1441.                     END;
  1442.                 END;
  1443.  
  1444.             { Make sure separate objects folder exists }
  1445.             IF NOT Exists(ObjApp) & (DirCreate(0, 0, ObjApp, dirID) <> noErr) THEN
  1446.                 BEGIN
  1447.                 Echo('''###'' MABuild: Unable to create directory: "{ObjApp}"');
  1448.                 Echo('MABuild of {XAppName} failed: `DATE`');
  1449.                 Execute('{MAFailed}');
  1450.  
  1451.                 IF fNoFail THEN
  1452.                     SetIE('XRunStatus', '1')
  1453.                 ELSE
  1454.                     Execute('EXIT 1');
  1455.                 END;
  1456.  
  1457.             { SET the BuildFlags }
  1458.             IF IEGetEnv('MABuildFlagsExtension', MABuildFlagsExtension) THEN;
  1459.             BuildFlags := concat(ObjApp, XAppName, MABuildFlagsExtension);
  1460.             SetIE('BuildFlags', BuildFlags);
  1461.  
  1462.             { Find out what the last option flags were }
  1463.             IF Exists(BuildFlags) THEN
  1464.                 Execute('EXECUTE "{BuildFlags}" ∑ Dev:NULL || SET Status 0')
  1465.             ELSE
  1466.                 SetIE('XLastOptionFlags', 'InvalidString');
  1467.  
  1468.             IF fExecute THEN
  1469.                 BEGIN
  1470.                 Execute('IF {XLastOptionFlags} != {XOptionFlags}');
  1471.              { the file BuildFlags will contain a SET command to set the value of XLastOptionFlags }
  1472.                  (* Was: Modified by Andreas Richter
  1473.                 Can't use MAEcho for replacement of Echo, because one will
  1474.                 go to the screen and the other into the output file.
  1475.                 Echo('"SET XLastOptionFlags {XOptionFlags}"  >  "{BuildFlags}"'); *)
  1476.                 Execute('Echo "SET XLastOptionFlags {XOptionFlags}" > "{BuildFlags}"');
  1477.                 Execute('END');
  1478.                 END;
  1479.  
  1480.             { Rebuild the application by creating the "MakeIt" file and then executing it }
  1481.             SetIE('XMakeIt', '{ObjApp}{XAppName}{MAMakeOutfileExtension}');
  1482.  
  1483. { SET the failure processing mode in the makeit files and (OPTIONALLY) the active environment vars into the makefile }
  1484.             (* Was: Modified by Andreas Richter
  1485.             IF fNoFail THEN
  1486.                 Echo('SET EXIT 0  > "{XMakeIt}"')
  1487.             ELSE
  1488.                 Echo('SET EXIT 1  > "{XMakeIt}"'); *)
  1489.             IF fNoFail THEN
  1490.                 Execute('Echo "SET EXIT 0"  > "{XMakeIt}"')
  1491.             ELSE
  1492.                 Execute('Echo "SET EXIT 1"  > "{XMakeIt}"');
  1493.  
  1494.             IF fExpandEnvironmentVars THEN
  1495.                 BEGIN
  1496.                 IF fStatusOnly THEN
  1497.                     SetIE('XMakeitRedirection', '')
  1498.                 ELSE
  1499.                     SetIE('XMakeitRedirection', ' >> ∂''{XMakeIt}∂''');
  1500.  
  1501.                 Execute('SET AsmOptions {XMakeitRedirection}');
  1502.                 Execute('SET BuildFlags {XMakeitRedirection}');
  1503.                 Execute('SET COptions {XMakeitRedirection}');
  1504.                 Execute('SET CPlusOptions {XMakeitRedirection}');
  1505.                 Execute('SET SCOptions {XMakeitRedirection}');
  1506.                 Execute('SET CPlusIncludesSC {XMakeitRedirection}');
  1507.                 Execute('SET MACPlus {XMakeitRedirection}');
  1508.                 Execute('SET CPlusCPUOptions {XMakeitRedirection}');
  1509.                 Execute('SET EchoOptions {XMakeitRedirection}');
  1510.                 Execute('SET LibOptions {XMakeitRedirection}');
  1511.                 Execute('SET LinkOptions {XMakeitRedirection}');
  1512.                 Execute('SET MakeOptions {XMakeitRedirection}');
  1513.                 Execute('SET ObjApp {XMakeitRedirection}');
  1514.                 Execute('SET PascalOptions {XMakeitRedirection}');
  1515.                 Execute('SET PascalCPUOptions {XMakeitRedirection}');
  1516.                 Execute('SET CreatorAndBundleOptions {XMakeitRedirection}');
  1517.                 Execute('SET RezOptions {XMakeitRedirection}');
  1518.                 Execute('SET SeparateObjectsFolder {XMakeitRedirection}');
  1519.                 Execute('SET SrcApp {XMakeitRedirection}');
  1520.                 Execute('SET XAppName {XMakeitRedirection}');
  1521.                 Execute('SET XAppName.cp {XMakeitRedirection}');
  1522.                 Execute('SET XAppName.cp.o {XMakeitRedirection}');
  1523.                 Execute('SET XAppName.p {XMakeitRedirection}');
  1524.                 Execute('SET XAppName.p.o {XMakeitRedirection}');
  1525.                 Execute('SET XAppRezSrc {XMakeitRedirection}');
  1526.                 Execute('SET XAutoRez {XMakeitRedirection}');
  1527.                 Execute('SET XLinkMap {XMakeitRedirection}');
  1528.                 Execute('SET XLinkXRef {XMakeitRedirection}');
  1529.                 Execute('SET XMAppName.cp {XMakeitRedirection}');
  1530.                 Execute('SET XMAppName.cp.o {XMakeitRedirection}');
  1531.                 Execute('SET XMAppName.p {XMakeitRedirection}');
  1532.                 Execute('SET XMAppName.p.o {XMakeitRedirection}');
  1533.                 Execute('SET XTimes {XMakeitRedirection}');
  1534.                 Execute('SET XRunAfterBuild {XMakeitRedirection}');
  1535.                 Execute('SET XUAppName.cp {XMakeitRedirection}');
  1536.                 Execute('SET XUAppName.cp.o {XMakeitRedirection}');
  1537.                 Execute('SET XUAppName.h {XMakeitRedirection}');
  1538.                 Execute('SET XUAppName.p {XMakeitRedirection}');
  1539.                 Execute('SET XUAppName.p.o {XMakeitRedirection}');
  1540.                 END;
  1541.  
  1542.             { Export the various and sundry environment variables }
  1543.             IF NOT fEverExported THEN
  1544.                 BEGIN
  1545.                 fEverExported := TRUE;                    { only need to export once }
  1546.                 Execute('EXPORT ∂');
  1547.                 Execute(
  1548.       'AsmOptions BuildFlags COptions MACPlus CPlusCPUOptions CPlusOptions SCOptions EchoOptions LibOptions LinkOptions MakeOptions CPlusIncludesSC ∂'
  1549.                         );
  1550.                 Execute(
  1551. 'ObjApp PascalCPUOptions PascalOptions CreatorAndBundleOptions RezOptions MAObj SeparateObjectsFolder SrcApp XAppName XAppName.cp XAppName.cp.o ∂'
  1552.                         );
  1553.                 Execute(
  1554.              'XAppName.p XAppName.p.o XAppRezSrc XAutoRez XLinkMap XLinkXRef XMakeit XMAppName.cp ∂'
  1555.                         );
  1556.                 Execute('XMAppName.cp.o XMAppName.p XMAppName.p.o XTimes XRunAfterBuild ∂');
  1557.                 Execute(
  1558.                  'XUAppName.cp XUAppName.cp.o XUAppName.h XUAppName.inc.p XUAppName.p XUAppName.p.o'
  1559.                         );
  1560.                 END;
  1561.  
  1562.             { Give user makefile processing status message }
  1563.             IF fProgress THEN
  1564.                 BEGIN
  1565.                 IF automake THEN
  1566.                     Echo('"AutoMaking:    {XAppName}"')
  1567.                 ELSE
  1568.                     Echo('"Making:        {XAppName}{MAMakeFileExtension}"');
  1569.                 END;
  1570.  
  1571.             IF fTimes THEN
  1572.                 SetIE('XMakeStartTime', '`DATE -n`');
  1573.             SetIE('EXIT', '0');
  1574.  
  1575.             { run make }
  1576.             Execute('{MAMake} {MakeOptions} ∂');
  1577.  
  1578.             IF (NOT fSymantec) THEN
  1579.                 BEGIN            { Delete support for Symantec libraries }
  1580.                 Execute('-d SymantecInit=  ∂');
  1581.                 Execute('-d SymantecLib=  ∂');
  1582.                 Execute('-d SymantecLib881=  ∂');
  1583.                 Execute('-d SymantecSystemSupport=  ∂');
  1584.                 Execute('-d SymantecNonFPUSANELib=  ∂');
  1585.                 Execute('-d SymantecFPUSANELib=  ∂');
  1586.                 Execute('-d SymantecUnmangleLib=  ∂');
  1587.  
  1588.                 { Select the proper floating point support }
  1589.                 IF fNeedsFPU THEN
  1590.                     Execute('-d NonFPUSANELib=  ∂')
  1591.                 ELSE
  1592.                     Execute('-d FPUSANELib=  ∂');
  1593.                 END
  1594.             ELSE
  1595.                 BEGIN            { Support for Symantec libraries }
  1596.                 Execute('-d SystemSupport=  ∂');
  1597.                 Execute('-d NonFPUSANELib=  ∂');
  1598.                 Execute('-d FPUSANELib=  ∂');
  1599.                 Execute('-d UnmangleLib=  ∂');
  1600.  
  1601.                 { Select the proper floating point support }
  1602.                 IF fNeedsFPU THEN
  1603.                     BEGIN
  1604.                     Execute('-d SymantecLib=  ∂');
  1605.                     Execute('-d SymantecNonFPUSANELib=  ∂');
  1606.                     END
  1607.                 ELSE
  1608.                     BEGIN
  1609.                     Execute('-d SymantecLib881=  ∂');
  1610.                     Execute('-d SymantecFPUSANELib=  ∂');
  1611.                     END;
  1612.                 END;
  1613.                 
  1614.             { Select the proper link libraries for modelfar support by eliminating the definition of
  1615.             ModelFarSupport if it's not used }
  1616.             
  1617.             IF NOT fModelFar THEN
  1618.                 BEGIN
  1619.                 Execute('-d ModelFarSupport=  ∂');
  1620.                 END;
  1621.  
  1622.             IF automake THEN
  1623.                 Execute('-d AppName={XAppName} ∂');     { the default rules supply the rest }
  1624.             Execute('-f "{MATools}Basic Definitions" ∂');
  1625.             IF NOT automake THEN
  1626.                 Execute('-f "{XAppPath}{XAppName}{MAMakeFileExtension}" ∂'); { a makefile was
  1627.                 supplied }
  1628.             Execute('-f "{MATools}Build Rules and Dependencies" ∂');
  1629.             Execute('"{ObjApp}{XAppName}" ∂');
  1630.             IF NOT fStatusOnly THEN
  1631.                 Execute('>> "{XMakeIt}"')
  1632.             ELSE
  1633.                 Execute('');
  1634.  
  1635.             SetIE('XMakeStatus', '{Status}');
  1636.             SetIE('EXIT', '1');
  1637.             Execute('IF "{XMakeStatus}"');
  1638.             Echo('MAKE of {XAppName} failed: `DATE`');
  1639.             IF fTimes THEN
  1640.                 Echo('Elapsed time: `evaluate ∂`DATE -n∂` - {XMakeStartTime}` seconds');
  1641.             Execute('{MAFailed}');
  1642.             IF fNoFail THEN
  1643.                 SetIE('XExitStatus', '{XMakeStatus}')
  1644.             ELSE
  1645.                 Execute('EXIT "{XMakeStatus}"');
  1646.  
  1647.             IF fTimes THEN
  1648.                 BEGIN
  1649.                 Execute('ELSE');
  1650.                 Echo('Elapsed time: `evaluate ∂`DATE -n∂` - {XMakeStartTime}` seconds');
  1651.                 END;
  1652.             Execute('END');
  1653.  
  1654.             { Attempt Execution and let the user know how it all came out }
  1655.             IF fExecute THEN
  1656.                 BEGIN
  1657.                 SetIE('EXIT', '0');
  1658.                 Execute('"{XMakeIt}"');
  1659.                 SetIE('XRunStatus', '{Status}');
  1660.                 SetIE('EXIT', '1');
  1661.                 Execute('IF "{XRunStatus}"');
  1662.                 Execute('{MAFailed}');
  1663.                 IF fNoFail THEN
  1664.                     SetIE('XExitStatus', '{XRunStatus}')
  1665.                 ELSE
  1666.                     Execute('EXIT "{XRunStatus}"');
  1667.                 Execute('END');
  1668.                 END;
  1669.             aTStringHandle := TStringHandle(fTargStringList.First);
  1670.             END;
  1671.         END;
  1672.  
  1673. {--------------------------------------------------------------------------------------------------}
  1674. {$S TRes}
  1675.  
  1676.     PROCEDURE TMABuildTool.DoToolAction;
  1677.  
  1678.         VAR
  1679.             SeparateObjectsFolder, MASeparateObjectsPrefix: Str255;
  1680.             MAAutoBuild:        Str255;
  1681.             MAUserAutoBuild:    Str255;
  1682.             MAShortVersion:     Str255;
  1683.             MALoadFiles, LoadFileDir, CPlusLoad: Str255;
  1684.             aTStringHandle:     TStringHandle;
  1685.             aString:            Str255;
  1686.             dirID:                Longint;
  1687.             vRefNum:            integer;
  1688.             i: integer;
  1689.  
  1690.             {* PathNameFromDirID ********************************************************}
  1691.  
  1692.         FUNCTION PathNameFromDirID(dirID: Longint;
  1693.                                    vRefNum: integer): Str255;
  1694.  
  1695.             CONST
  1696.                 fsRtDir             = 2;
  1697.  
  1698.             VAR
  1699.                 Block:                CInfoPBRec;
  1700.                 directoryName, FullPathName: Str255;
  1701.                 err:                oserr;
  1702.  
  1703.             BEGIN
  1704.             FullPathName := '';
  1705.             WITH Block DO
  1706.                 BEGIN
  1707.                 ioNamePtr := @directoryName;
  1708.                 ioDrParID := dirID;
  1709.                 END;
  1710.  
  1711.             REPEAT
  1712.                 WITH Block DO
  1713.                     BEGIN
  1714.                     ioVRefNum := vRefNum;
  1715.                     ioFDirIndex := - 1;
  1716.                     ioDrDirID := Block.ioDrParID;
  1717.                     END;
  1718.                 err := PBGetCatInfo(@Block, FALSE);
  1719.  
  1720.                 directoryName := concat(directoryName, ':');
  1721.                 
  1722.                 FullPathName := concat(directoryName, FullPathName);
  1723.             UNTIL (Block.ioDrDirID = fsRtDir);
  1724.  
  1725.             PathNameFromDirID := FullPathName;
  1726.             END;
  1727.  
  1728.         BEGIN
  1729.  
  1730.         IF NOT IEGetEnv('MAShortVersion', MAShortVersion) | (MAShortVersion <> '3.0.1') THEN
  1731.             BEGIN
  1732.             Stop(
  1733.            '''###'' MABuild: Whoops… You have not executed the Startup file in the MacApp directory'
  1734.                  );
  1735.             END;
  1736.         { Resolve matrix of options. }
  1737.         IF NOT fProgress THEN
  1738.             fEchoOptions.Catenate(' ∑ Dev:NULL ');
  1739.         IF fDebug THEN
  1740.             fNames := TRUE;
  1741.  
  1742. {!!!!!#### still need parsing loops to process each of these as multiple targets if the var is a list }
  1743.         IF fUserAutoBuild & IEGetEnv('MAUserAutoBuild', MAUserAutoBuild) & (MAUserAutoBuild <>
  1744.            '') THEN
  1745.             BEGIN
  1746.             WHILE (length(MAUserAutoBuild) <> 0) DO
  1747.                 BEGIN
  1748.                 i := pos(',', MAUserAutoBuild);
  1749.                 IF i = 0 THEN
  1750.                     i := length(MAUserAutoBuild)
  1751.                 ELSE
  1752.                     i := i - 1;
  1753.                 aTStringHandle := NewTStringHandle;
  1754.                 aTStringHandle.Catenate(Copy(MAUserAutoBuild, 1, i));
  1755.                 fTargStringList.InsertFirst(aTStringHandle);
  1756.                 Delete(MAUserAutoBuild, 1, min(i + 1, length(MAUserAutoBuild))); { toss the target &
  1757.                     ,}
  1758.                 END;
  1759.             END;
  1760.  
  1761.         IF fAutoBuild & IEGetEnv('MAAutoBuild', MAAutoBuild) & (MAAutoBuild <> '') THEN
  1762.             BEGIN
  1763.             WHILE (length(MAAutoBuild) <> 0) DO
  1764.                 BEGIN
  1765.                 i := pos(',', MAAutoBuild);
  1766.                 IF i = 0 THEN
  1767.                     i := length(MAAutoBuild)
  1768.                 ELSE
  1769.                     i := i - 1;
  1770.                 aTStringHandle := NewTStringHandle;
  1771.                 aTStringHandle.Catenate(Copy(MAAutoBuild, 1, i));
  1772.                 fTargStringList.InsertFirst(aTStringHandle);
  1773.                 Delete(MAAutoBuild, 1, min(i + 1, length(MAAutoBuild))); { toss the target & ,}
  1774.                 END;
  1775.             END;
  1776.  
  1777.         { Building for use with MacApp? }
  1778.         IF fMacApp THEN
  1779.             CatenateToSourceOptionStrings(' -d qMacApp=TRUE')
  1780.         ELSE
  1781.             CatenateToSourceOptionStrings(' -d qMacApp=FALSE');
  1782.  
  1783.         IF fAlign THEN
  1784.             BEGIN
  1785.             fLinkOptions.Catenate(' -ac 4 -ad 4');
  1786.             fRezOptions.Catenate(' -align longword');
  1787.             END;
  1788.  
  1789.         { process elapsed time indication }
  1790.         IF fTimes THEN
  1791.             BEGIN
  1792.             fAsmOptions.Catenate(' -t');
  1793.             fCOptions.Catenate(' -t');
  1794.             fCPlusOptions.Catenate(' -t');
  1795.             { fSCOptions.Catenate(' -t'); # there isn't a -t option }
  1796.             { fLinkOptions.Catenate(' -t'); # -t means file type }
  1797.             { fLibOptions.Catenate(' -t'); # there isn't a -t option }
  1798.             { fMakeOptions.Catenate(' -t'); # -t means touch the files }
  1799.             fPascalOptions.Catenate(' -t');
  1800.             { fRezOptions.Catenate(' -t');     # -t means file type }
  1801.             fCreatorAndBundleOptions.Catenate(' -t');
  1802.             END;
  1803.  
  1804.         { Progress indication }
  1805.         IF fAllProgress THEN
  1806.             BEGIN
  1807.             CatenateToSourceOptionStrings(' -p');
  1808.             fLinkOptions.Catenate(' -p');
  1809.             fLibOptions.Catenate(' -p');
  1810.             fCreatorAndBundleOptions.Catenate(' -p');
  1811.             END;
  1812.  
  1813.         IF fBottleNeckedDispatching THEN
  1814.             fLinkOptions.Catenate(' -opt NoBypass')
  1815.         ELSE
  1816.             fLinkOptions.Catenate(' -opt on');
  1817.  
  1818.         { PreSystem 7.0 support }
  1819.         IF fNeedsSystem7 THEN
  1820.             BEGIN
  1821.             fOptionFlags.Catenate('S7');
  1822.  
  1823.             CatenateToSourceOptionStrings(
  1824. ' -d qNeedsAppleEventMgr=TRUE -d qNeedsEditionMgr=TRUE -d qNeedsHelpMgr=TRUE -d qNeedsProcessMgr=TRUE -d qNeedsAliasMgr=TRUE -d qNeedsFolderMgr=TRUE -d qNeedsSystem7=TRUE -d SystemSevenOrLater=TRUE'
  1825.                                           );
  1826.             END
  1827.         ELSE
  1828.             CatenateToSourceOptionStrings(
  1829. ' -d qNeedsAppleEventMgr=FALSE -d qNeedsEditionMgr=FALSE -d qNeedsHelpMgr=FALSE -d qNeedsProcessMgr=FALSE -d qNeedsAliasMgr=FALSE -d qNeedsFolderMgr=FALSE -d qNeedsSystem7=FALSE -d SystemSevenOrLater=FALSE'
  1830.                                           );
  1831.  
  1832.         { ColorQD support }
  1833.         IF fNeedsColorQD THEN
  1834.             BEGIN
  1835.             fOptionFlags.Catenate('Cq');
  1836.  
  1837.             CatenateToSourceOptionStrings(' -d qNeedsColorQD=TRUE');
  1838.             END
  1839.         ELSE
  1840.             CatenateToSourceOptionStrings(' -d qNeedsColorQD=FALSE');
  1841.  
  1842.         { 020 support }
  1843.         IF fNeedsMC68020 THEN
  1844.             BEGIN
  1845.             fOptionFlags.Catenate('20');
  1846.  
  1847.             CatenateToSourceOptionStrings(' -d qNeedsMC68020=TRUE');
  1848.             fCPlusCPUOptions.Catenate(' -mc68020');
  1849.             fPascalCPUOptions.Catenate(' -mc68020');
  1850.             END
  1851.         ELSE
  1852.             CatenateToSourceOptionStrings(' -d qNeedsMC68020=FALSE');
  1853.  
  1854.         { 030 support }
  1855.         IF fNeedsMC68030 THEN
  1856.             BEGIN
  1857.             fOptionFlags.Catenate('30');
  1858.  
  1859.             CatenateToSourceOptionStrings(' -d qNeedsMC68030=TRUE');
  1860.             fCPlusCPUOptions.Catenate(' -mc68020');
  1861.             fPascalCPUOptions.Catenate(' -mc68020');
  1862.             END
  1863.         ELSE
  1864.             CatenateToSourceOptionStrings(' -d qNeedsMC68030=FALSE');
  1865.  
  1866.         { FPU support }
  1867.         IF fNeedsFPU THEN
  1868.             BEGIN
  1869.             fOptionFlags.Catenate('Fp');
  1870.  
  1871.             CatenateToSourceOptionStrings(' -d qNeedsFPU=TRUE');
  1872.             fCPlusCPUOptions.Catenate(' -mc68881 -elems881');
  1873.             fPascalCPUOptions.Catenate(' -mc68881 -d elems881=TRUE');
  1874.             END
  1875.         ELSE
  1876.             BEGIN
  1877.             CatenateToSourceOptionStrings(' -d qNeedsFPU=FALSE');
  1878.             END;
  1879.  
  1880.         { MacApp as library support }
  1881.         IF fMALibrary THEN
  1882.             BEGIN
  1883.             fMakeOptions.Catenate(' -d MacAppObjs=  ');
  1884.             END
  1885.         ELSE
  1886.             BEGIN
  1887.             fMakeOptions.Catenate(' -d MacAppLibrary=  ');
  1888.             END;
  1889.  
  1890.         IF NOT fPasLoad THEN
  1891.             BEGIN
  1892.             fPascalOptions.Catenate(' -noload ');
  1893.             fMakeOptions.Catenate(' -d PascalLoadFolder=  ');
  1894.             END;
  1895.             
  1896.         { Pascal external symbol table files support }
  1897.         IF NOT fPasLoadSeparateFolder THEN
  1898.             BEGIN
  1899.             fMakeOptions.Catenate(' -d PascalLoadFolder=  ');
  1900.             END;
  1901.  
  1902.         { Virtual User support }
  1903.         IF fNeedsVU THEN
  1904.             BEGIN
  1905.             fOptionFlags.Catenate('Vu');
  1906.  
  1907.             CatenateToSourceOptionStrings(' -d qNeedsVU=TRUE');
  1908.             END
  1909.         ELSE
  1910.             CatenateToSourceOptionStrings(' -d qNeedsVU=FALSE');
  1911.  
  1912.         { The Debugger support }
  1913.         IF fTheDebugger THEN
  1914.             BEGIN
  1915.             fOptionFlags.Catenate('J');
  1916.  
  1917.             CatenateToSourceOptionStrings(' -d qTheDebugger=TRUE');
  1918.             END
  1919.         ELSE
  1920.             CatenateToSourceOptionStrings(' -d qTheDebugger=FALSE');
  1921.  
  1922.         IF NOT fCPlusLoad THEN
  1923.             BEGIN
  1924.             fMakeOptions.Catenate(' -d CPlusLoad=  -d CPlusLoadObj=  -d CPlusLoadOptions=  '); { Remove the
  1925.                 definitions }
  1926.             END;
  1927.  
  1928.         { Embedded debugger names }
  1929.         IF fNames THEN
  1930.             BEGIN
  1931.             fOptionFlags.Catenate('Nm');
  1932.  
  1933.             CatenateToSourceOptionStrings(' -d qNames=TRUE');
  1934. {$IFC FALSE}                                            { !!! not until 32bit everything… gets too
  1935.                                                          big! }
  1936.             IF IEGetEnv('MAShellVersion', MAShellVersion) & (MAShellVersion <> '3.0.1') THEN
  1937.                 fLinkOptions.Catenate(' -opt names');    { Make the selector procs show up }
  1938. {$EndC}
  1939.             END
  1940.         ELSE
  1941.             BEGIN
  1942.             CatenateToSourceOptionStrings(' -d qNames=FALSE');
  1943.             fCOptions.Catenate(' -mbg off');
  1944.             fCPlusOptions.Catenate(' -mbg off');
  1945.             fSCOptions.Catenate(' -mbg off');
  1946.             END;
  1947.  
  1948.         { Debugging support }
  1949.         IF fDebug THEN
  1950.             BEGIN
  1951.             fOptionFlags.Catenate('Db');
  1952.  
  1953.             CatenateToSourceOptionStrings(' -d qDebug=TRUE');
  1954.             fRezOptions.Catenate(' -d Debugging');        { For backward compatibility. To be dropped
  1955.                                                          in next release (post 2.0)}
  1956.             END
  1957.         ELSE
  1958.             BEGIN
  1959.             CatenateToSourceOptionStrings(' -d qDebug=FALSE');
  1960.             fMakeOptions.Catenate(' -d DebugFiles= -d DebugRsrcs= -d DebugLib=  '); { Eliminate
  1961.                 debug files as targets in the makefiles }
  1962.             END;
  1963.  
  1964.         { Debug messages support }
  1965.         IF fDebugMsg THEN
  1966.             BEGIN
  1967.             fOptionFlags.Catenate('Dm');
  1968.             CatenateToSourceOptionStrings(' -d qDebugMsg=TRUE');
  1969.             END
  1970.         ELSE
  1971.             BEGIN
  1972.             CatenateToSourceOptionStrings(' -d qDebugMsg=FALSE');
  1973.             END;
  1974.  
  1975.         { UnInitialized storage support }
  1976.         IF fUnInit THEN
  1977.             BEGIN
  1978.             fOptionFlags.Catenate('Un');
  1979.  
  1980.             CatenateToSourceOptionStrings(' -d qUnInit=TRUE');
  1981.             END
  1982.         ELSE
  1983.             CatenateToSourceOptionStrings(' -d qUnInit=FALSE');
  1984.  
  1985.         { Perform support }
  1986.         IF fPerform THEN
  1987.             BEGIN
  1988.             fOptionFlags.Catenate('Pe');
  1989.  
  1990.             CatenateToSourceOptionStrings(' -d qPerform=TRUE');
  1991.             END
  1992.         ELSE
  1993.             BEGIN
  1994.             CatenateToSourceOptionStrings(' -d qPerform=FALSE');
  1995.             fMakeOptions.Catenate(' -d PerformLib= ');    { Eliminate the performance libraries as
  1996.                                                          target }
  1997.             END;
  1998.  
  1999.         { RangeCheck support }
  2000.         IF fRangeCheck THEN
  2001.             BEGIN
  2002.             fOptionFlags.Catenate('Ra');
  2003.  
  2004.             CatenateToSourceOptionStrings(' -d qRangeCheck=TRUE');
  2005.             END
  2006.         ELSE
  2007.             CatenateToSourceOptionStrings(' -d qRangeCheck=FALSE');
  2008.  
  2009.         { template views support }
  2010.         IF fTemplateViews | fTwoOhTemplateViews THEN
  2011.             BEGIN
  2012.             fOptionFlags.Catenate('Te');
  2013.  
  2014.             CatenateToSourceOptionStrings(' -d qTemplateViews=TRUE');
  2015.             END
  2016.         ELSE
  2017.             CatenateToSourceOptionStrings(' -d qTemplateViews=FALSE');
  2018.  
  2019.         { writing template views support }
  2020.         IF fWriteTemplateViews THEN
  2021.             BEGIN
  2022.             fOptionFlags.Catenate('Wr');
  2023.  
  2024.             CatenateToSourceOptionStrings(' -d qWriteTemplateViews=TRUE');
  2025.             END
  2026.         ELSE
  2027.             CatenateToSourceOptionStrings(' -d qWriteTemplateViews=FALSE');
  2028.  
  2029.         { 2.0 template views support }
  2030.         IF fTwoOhTemplateViews THEN
  2031.             BEGIN
  2032.             fOptionFlags.Catenate('2T');
  2033.  
  2034.             CatenateToSourceOptionStrings(' -d qTwoOhTemplateViews=TRUE');
  2035.             END
  2036.         ELSE
  2037.             CatenateToSourceOptionStrings(' -d qTwoOhTemplateViews=FALSE');
  2038.  
  2039.         { symbolic debugging support }
  2040.         IF fSym THEN
  2041.             BEGIN
  2042.             fOptionFlags.Catenate('Sm');
  2043.  
  2044.             CatenateToSourceOptionStrings(' -d qSym=TRUE');
  2045.             fAsmOptions.Catenate(' -sym on');
  2046.             fCOptions.Catenate(' -sym on');
  2047.             fCPlusOptions.Catenate(' -sym on');
  2048.             fSCOptions.Catenate(' -sym on');
  2049.             fLinkOptions.Catenate(' -sym on');
  2050.             fPascalOptions.Catenate(' -sym on');
  2051.             END
  2052.         ELSE
  2053.             CatenateToSourceOptionStrings(' -d qSym=FALSE');
  2054.  
  2055.         IF fModelFar THEN
  2056.             BEGIN
  2057.             fOptionFlags.Catenate('fCfD');
  2058.             fPascalOptions.Catenate(' -model farCode -model farData');
  2059.             fCOptions.Catenate(' -model farCode -model farData');
  2060.             fAsmOptions.Catenate(' -model far');
  2061.             fLinkOptions.Catenate(' -model far');
  2062.             fCPlusOptions.Catenate(' -model far');
  2063.             fSCOptions.Catenate(' -model far');
  2064.  
  2065.             CatenateToSourceOptionStrings(' -d qModelFarData=TRUE');
  2066.             CatenateToSourceOptionStrings(' -d qModelFarCode=TRUE');
  2067.             END
  2068.         ELSE
  2069.             BEGIN
  2070.             CatenateToSourceOptionStrings(' -d qModelFarData=FALSE');
  2071.             CatenateToSourceOptionStrings(' -d qModelFarCode=FALSE');
  2072.             fLinkOptions.Catenate(' -wrap');
  2073.             END;
  2074.  
  2075.         { Process separate objects }
  2076.         { Get basic name }
  2077.         IF fSeparateObjects THEN
  2078.             BEGIN
  2079.             IF NOT fRenameFlagsPairs.ValueAt(fOptionFlags.AsStr255, SeparateObjectsFolder) THEN
  2080.                 SeparateObjectsFolder := fOptionFlags.AsStr255;
  2081.             END
  2082.         ELSE
  2083.             BEGIN
  2084.             IF NOT IEGetEnv('MANoSeparateObjectsFolder', SeparateObjectsFolder) THEN
  2085.                 SeparateObjectsFolder := '';
  2086.             END;
  2087.  
  2088.         { Add the compiler }
  2089.         IF fSymantec THEN
  2090.             SeparateObjectsFolder := concat(SeparateObjectsFolder,'SC');
  2091.             
  2092.         { Add the prefix }
  2093.         IF IEGetEnv('MASeparateObjectsPrefix', MASeparateObjectsPrefix) THEN
  2094.             SeparateObjectsFolder := concat(MASeparateObjectsPrefix, SeparateObjectsFolder,
  2095.                                             gDirectorySeparator);
  2096.  
  2097.         SetIE('SeparateObjectsFolder', SeparateObjectsFolder);
  2098.         fSeparateObjectsFolder := SeparateObjectsFolder;
  2099.  
  2100.         { Include Any unconditional options that we might want to force on unsuspecting
  2101.         tools but haven't the gall to include in the startup file.
  2102.         }
  2103.  
  2104.         { Rename some procedures so that they can be accessed from C++ }
  2105.         fLinkOptions.Catenate(' -ma __OBNEW=%_OBNEW -ma __PGM1=%_PGM1 -ma __EP=%_EP -ma __BP=%_BP -ma __EX=%_EX');
  2106.  
  2107.         { ensure that when this segment gets loaded it goes down as low in the heap as possible }
  2108.         fLinkOptions.Catenate(' -ra MAMain=resLocked');
  2109.  
  2110.         { output the results. }
  2111.         IF fTimes THEN
  2112.             WriteLn(fOutputFile^, 'SET XStartTime ', fStartDateTime);
  2113.             
  2114.         WriteLn(fOutputFile^, 'SET XTimes ', ord(fTimes));
  2115.         WriteLn(fOutputFile^, 'SET XRunAfterBuild ', ord(fRunAfterBuild));
  2116.  
  2117.         Write(fOutputFile^, 'SET AsmOptions "'); fAsmOptions.WriteToFile(fOutputFile);
  2118.         WriteLn(fOutputFile^, ' "');
  2119.         
  2120.         Write(fOutputFile^, 'SET COptions "'); fCOptions.WriteToFile(fOutputFile);
  2121.         WriteLn(fOutputFile^, ' "');
  2122.         
  2123.         IF fSymantec THEN
  2124.             BEGIN
  2125.             SetIE('CPlusOptions', '');
  2126.             WriteLn(fOutputFile^, 'SET MACPlus "''{MPW}SCBin:SCpp''" ');
  2127.             WriteLn(fOutputFile^, 'SET CPlusIncludesSC "{MacApp}CPlusIncludesSC:" ');
  2128.             Write(fOutputFile^, 'SET SCOptions "'); fSCOptions.WriteToFile(fOutputFile);
  2129.             END
  2130.         ELSE
  2131.             BEGIN
  2132.             SetIE('SCOptions', '');
  2133.             SetIE('CPlusIncludesSC', '');
  2134.             Write(fOutputFile^, 'SET CPlusOptions "'); fCPlusOptions.WriteToFile(fOutputFile);
  2135.             END;
  2136.         WriteLn(fOutputFile^, ' "');
  2137.         
  2138.         Write(fOutputFile^, 'SET CPlusCPUOptions "'); fCPlusCPUOptions.WriteToFile(fOutputFile);
  2139.         WriteLn(fOutputFile^, ' "');
  2140.         Write(fOutputFile^, 'SET EchoOptions "'); fEchoOptions.WriteToFile(fOutputFile);
  2141.         WriteLn(fOutputFile^, ' "');
  2142.         Write(fOutputFile^, 'SET LibOptions "'); fLibOptions.WriteToFile(fOutputFile);
  2143.         WriteLn(fOutputFile^, ' "');
  2144.         Write(fOutputFile^, 'SET LinkOptions "'); fLinkOptions.WriteToFile(fOutputFile);
  2145.         WriteLn(fOutputFile^, ' "');
  2146.         Write(fOutputFile^, 'SET MakeOptions "'); fMakeOptions.WriteToFile(fOutputFile);
  2147.         WriteLn(fOutputFile^, ' "');
  2148.         Write(fOutputFile^, 'SET PascalCPUOptions "'); fPascalCPUOptions.WriteToFile(fOutputFile);
  2149.         WriteLn(fOutputFile^, ' "');
  2150.         Write(fOutputFile^, 'SET PascalOptions "'); fPascalOptions.WriteToFile(fOutputFile);
  2151.         WriteLn(fOutputFile^, ' "');
  2152.         Write(fOutputFile^, 'SET RezOptions "'); fRezOptions.WriteToFile(fOutputFile);
  2153.         WriteLn(fOutputFile^, ' "');
  2154.         Write(fOutputFile^, 'SET CreatorAndBundleOptions "');
  2155.         fCreatorAndBundleOptions.WriteToFile(fOutputFile);
  2156.         WriteLn(fOutputFile^, ' "');
  2157.  
  2158.         Write(fOutputFile^, 'SET XOptionFlags "'); fOptionFlags.WriteToFile(fOutputFile);
  2159.         WriteLn(fOutputFile^, '"');
  2160.  
  2161.         { Process autosave }
  2162.         IF fSaveBeforeBuild THEN
  2163.             BEGIN
  2164.             IF fProgress THEN
  2165.                 Echo('"AutoSaving…"');
  2166.             Execute('Save -a');
  2167.             END;
  2168.  
  2169.         { Remember the current directory }
  2170.         IF HGetVol(NIL, vRefNum, dirID) = noErr THEN
  2171.             fStartPath := PathNameFromDirID(dirID, vRefNum);
  2172.  
  2173.         { Make sure load files folder and separate objects folder exists for load files}
  2174.         IF IEGetEnv('MALoadFiles', MALoadFiles) THEN
  2175.             LoadFileDir := concat(MALoadFiles, fSeparateObjectsFolder)
  2176.         ELSE                                            { Punt }
  2177.             LoadFileDir := concat(MALoadFiles, fSeparateObjectsFolder);
  2178.         { Make sure the basic load files directory exists }
  2179.         IF (MALoadFiles <> '') & NOT Exists(MALoadFiles) & (DirCreate(0, 0, MALoadFiles, dirID) <>
  2180.            noErr) THEN
  2181.             BEGIN
  2182.             Echo('''###'' MABuild: Unable to create directory: "{MALoadFiles}"');
  2183.             Echo('MABuild of {XAppName} failed: `DATE`');
  2184.             Execute('{MAFailed}');
  2185.  
  2186.             IF fNoFail THEN
  2187.                 SetIE('XRunStatus', '1')
  2188.             ELSE
  2189.                 Execute('EXIT 1');
  2190.             END;
  2191.         { Make sure the load files directory that is specific to our build options exists }
  2192.         IF NOT Exists(LoadFileDir) & (DirCreate(0, 0, LoadFileDir, dirID) <> noErr) THEN
  2193.             BEGIN
  2194.             Echo(
  2195.                '''###'' MABuild: Unable to create directory: "{MALoadFiles}{SeparateObjectsFolder}"'
  2196.                  );
  2197.             Echo('MABuild of {XAppName} failed: `DATE`');
  2198.             Execute('{MAFailed}');
  2199.  
  2200.             IF fNoFail THEN
  2201.                 SetIE('XRunStatus', '1')
  2202.             ELSE
  2203.                 Execute('EXIT 1');
  2204.             END;
  2205.  
  2206.         { process each target in the list }
  2207.         DoAllTargets;
  2208.  
  2209.         { termination messages }
  2210.         IF fTimes THEN
  2211.             BEGIN
  2212.             Echo('" "');
  2213.             Echo('MABuild:   Elapsed time: `evaluate ∂`DATE -n∂` - {XStartTime}` seconds');
  2214.             END;
  2215.  
  2216.         Execute('IF "{XExitStatus}"');
  2217.         Execute('{MAFailed}');
  2218.         Execute('EXIT "{XExitStatus}"');
  2219.         Execute('END');
  2220.  
  2221.         IF fProgress THEN
  2222.             BEGIN
  2223.             Echo('Completion time for MABuild is `DATE`');
  2224.             Execute('{MADone}');
  2225.             END;
  2226.         END;
  2227. {--------------------------------------------------------------------------------------------------}
  2228. {$S TRes}
  2229.  
  2230.     BEGIN
  2231.     InitUPascalTool;
  2232.  
  2233.     New(gMABuildTool);
  2234.     gMABuildTool.IMABuildTool;
  2235.     gMABuildTool.Run;
  2236.     END.
  2237.